$(document).ready ->
  App.notice = App.cable.subscriptions.create { channel: "NoticeChannel"},
    connected: ->
      console.log "cable is connected"
      # Called when the subscription is ready for use on the server

    disconnected: ->
      # Called when the subscription has been terminated by the server

    received: (data) ->
      if data && data.project_id
        if data.command_name =='complete'
          $(".project-do-action-form input[type='submit']").removeAttr('disabled')
          $(".modal-operation-log[data-id='"+data.project_id+"'] .start-exec-info").html("执行完毕").removeClass('text-warning')
        html = "<div><div class='log-command-text'>"+
          data.command_text+
          "</div><pre>"+
          data.result+
          "</pre></div>"
        $(".modal-operation-log[data-id='"+data.project_id+"'] .logs").prepend(html)
        if $('.project-show-page-log').length>0
          $('.project-show-page-log tbody').prepend("<tr>" +
            "<td>"+data.command_name+"</td>"+
            "<td>"+data.user+"</td>"+
            "<td>"+data.created_at+"</td>"+
            "</tr>")
